<?php
/**
 * Created by PhpStorm.
 * User: lijie
 * Date: 2018/10/3
 * Time: 13:46
 */
namespace app\api\model;

use think\Model;

class Yearcard extends Model{
    protected $autoWriteTimestamp = true;
    protected $dateFormat;
    protected $insert = ['status'=>0];

    /**
     * Notes:  添加优惠券产品
     * Create Date: 2018/10/3
     * Create by :lijie
     */
    public function addCoupon($data)
    {
        return $this->isUpdate(false)->allowField(true)->save($data);
    }

    /**
     * Notes:  删除优惠券产品
     * Create Date: 2018/10/3
     * Create by :lijie
     */
    public function delYear($data)
    {
        return $this->isUpdate(true)->save(['status'=>9],['id'=>$data]);
    }

    /**
     * Notes:  编辑优惠券产品
     * Create Date: 2018/10/3
     * Create by :lijie
     */
    public function editCoupon($data,$where)
    {
        return $this->isUpdate(true)->allowField(true)->save($data,$where);
    }

    /**
     * Notes:  查看年卡
     * Create Date: 2018/10/3
     * Create by :lijie
     */
    public function yearCardList($where,$pagenum=1,$listNum=10)
    {
        return $this->where($where)->order("create_time desc")->page($pagenum,$listNum)->select();
    }

    /**
     * Notes:  优惠券产品详情
     * Create Date: 2018/10/3
     * Create by :lijie
     */
    public function yearInfo($param)
    {
        return $this->where($param)->find();
    }
}